<template>
  <div id="collapsed" @click="handleCollapsed">
    <i v-if="appState.collapsed" class="iconfont icon-dakai" />
    <i v-else class="iconfont icon-guanbi" />
  </div>
</template>

<script>
import { computed } from 'vue'
import { useStore } from 'vuex'

export default {
  setup() {
    const store = useStore()
    const appState = computed(() => store.state.app).value

    const handleCollapsed = () => {
      store.commit('app/SET_COLLAPSED', !appState.collapsed)
    }

    return {
      appState,
      handleCollapsed
    }
  }
}
</script>

<style lang="scss" scoped>
#collapsed {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  .anticon {
    font-size: 20px;
  }
}
</style>
